<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function page($pageNumber,$db,$where=array(),$array=array()){
    $all=$db->where($where)->field("count(*) as count")->find();
    $rs['allnumber']=$all['count'];
    $rs['number']=$pageNumber;
    $rs['allpage']= ceil($rs['allnumber']/$rs['number']);
    if(isset($_GET['page'])&&  intval($_GET['page'])>1){
        $page=  intval($_GET['page']);
    }else{
        $page=1;
    }
    $rs['page']=$page;
    $rs['start']=($page-1)*$pageNumber;
    //上一页
    $array['page']=$page-1;
    $rs['ppage']=U("",$array);
    //下一页
    $array['page']=$page+1;
    $rs['npage']=U("",$array);
    //首页
    $array['page']=1;
    $rs['index']=U("",$array);
    //末页
    $array['page']=$rs['allpage'];
    $rs['last']=U("",$array);
    
    return $rs;
}
?>
